<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<title>内容分发平台</title>
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<meta http-equiv="content-type" content="text/html; charset=UTF-8">
		<link rel="stylesheet" type="text/css" href="resources/jquery-easyui-1.5.3/themes/default/easyui.css">
		<link rel="stylesheet" type="text/css" href="resources/jquery-easyui-1.5.3/themes/icon.css">
		<script type="text/javascript" src="resources/jquery-easyui-1.5.3/jquery.min.js"></script>
		<script type="text/javascript" src="resources/jquery-easyui-1.5.3/jquery.easyui.min.js"></script>
		<script type="text/javascript" src="js/md5.js"></script>
		
		<style type="text/css">
	        #tt .panel-body-noborder{overflow: hidden;}
    	</style>
		
		
		<script type="text/javascript">
		if(document.referrer !="http://gyp.meidongya.cn/html/login.html"){
			$(location).attr('href', 'login.html');
		}
			var tree = function () {
				$("#tree").tree({
					url:'http://gyp.meidongya.cn/SysUser/get_cate',//http://gyp.meidongya.cn/public/get_cate
					method: 'POST',
					animate: true,
					checkbox: false,
					cascadeCheck:false,//层叠选中
					lines:true,
					onClick: function(node){
						//console.log(node);
						add_tabs(node);
					}
				});
			}
			var tabs = function(){
				$('#tt').tabs({
				    border:false,
				    onSelect:function(titile){
						//alert(title+' is selected');
				    }
				});
			}
			var add_tabs = function(node){
				title = node.text;
				id = node.id;
				att = node.attributes;
				if(att != undefined){
					url = att.url;
					if(url != undefined){
						if(!$('#tt').tabs('exists',title)){
							$('#tt').tabs('add',{
								id:id,
							    title:title,
							    border: false,
							    content:'<iframe scrolling="all" frameborder="0"  src="'+url+'" style="width:100%;height:100%;"></iframe>',
							    closable:true
							});
						}else{
							$('#tt').tabs('select',title);
						}
					}
				}
			}

			$(function (){
				tree();
				tabs();
				$.extend($.fn.validatebox.defaults.rules, {  
			    /*必须和某个字段相等*/
			    equalTo: {
			        validator:function(value,param){
			            return $(param[0]).val() == value;
			        },
			        message:'字段不匹配'
			    }
			           
			});

			$('#upass').click(function (){
                $('#uppass').dialog('open');
            })

			$('#logout').click(function (){
				$.messager.confirm('确定操作', '您确定要退出吗？', function (flag) {
					if (flag) {
						$.ajax({
		                    type:'post',
		                    url:'http://gyp.meidongya.cn/public/logout',
		                    success:function(data){
		                    	console.log(data)
		                    	if(data == 1){
		                    		$(location).attr('href', 'login.html');		
		                    	}
		                    }
		                })
					}
					});
            })

			$('#uppass').dialog({
				width : 350,
				title : '修改密码',
				modal : true,
				closed : true,
				iconCls : 'icon-user_suit',
				buttons : [{
					text : '确定',
					iconCls : 'icon-accept',
					handler : function () {
						if ($('#uppass').form('validate')) {
							$.ajax({
								url : 'http://gyp.meidongya.cn/SysUser/modify_pass',
								type : 'POST',
								data : {
									oldpass : $.md5($('input[name="oldpass"]').val()),
									newpass : $.md5($('input[name="newpass"]').val()),
								},
								beforeSend : function () {
									$.messager.progress({
										text : '正在修改中...',
									});
								},
								success : function (data, response, status) {
									$.messager.progress('close');
									
									if (data == 1) {
										$.messager.show({
											title : '提示',
											msg : '修改成功',
										});
									} else if(data == 2){
										$.messager.alert('修改失败！', '密码不能和之前相同，请重试！', 'warning');
									} else{
										$.messager.alert('修改失败！', '修改失败！', 'warning');
									}
									$('#uppass').dialog('close');
								}
							});
						}
					},
				},{
					text : '取消',
					iconCls : 'icon-redo',
					handler : function () {
						$('#uppass').dialog('close');
					},
				}],
			});
				
				
			});
			//console.log(document.referrer)
		</script>
	</head>
	<body class="easyui-layout">
	    <div data-options="region:'north',split:false" style="height:80px;background-image: url('images/c.png');">
			<p style="width: 400px;height: 80px;font-size: 24px;position: absolute;margin-bottom: 20px;margin-left: 50px;color: #fdfdfd">光伏微网能量管理系统</p>
            <p>当前用户：guoyipei</p> <span style="margin-left: 200px">当前时间：</span>
            <a href='javascript:void(0)' id='logout' style="position: absolute;right:30px;top:10px;font-size: 15px;font-family:'幼圆';"; >退出</a>
			<a href='javascript:void(0)' id='upass'  style="position: absolute;right:70px;top:10px;font-size: 15px;font-family:'幼圆';">修改密码</a>		
	    </div>
	    <div data-options="region:'west',title:'导航',split:true" style="width:180px;">
	    	<ul id="tree" ></ul>
	    </div>
	    <div data-options="region:'center',title:''" style="background:#eee;" id = "tt"> 	
	    </div>
	    <form id="uppass" style="margin:0;padding:5px 0 0 25px;color:#333;">
			<p>原 密 码: <input type="password" validType="length[4,16]" invalidMessage="密码长度4-16位" class="easyui-validatebox" required="true" name="oldpass" class="textbox" style="width:205px;"></p>
			<p>新 密 码: <input type="password" id="newpass" validType="length[4,16]" class="easyui-validatebox" required="true" class="textbox" name="newpass" style="width:205px;"></p>
			<p>新 密 码: <input type="password" id="newagain" required="true" class="easyui-validatebox"  validType="equalTo['#newpass']" invalidMessage="两次输入密码不匹配" class="textbox" name="newagain" style="width:205px;"></p>
		</form>
	</body>
</html>
